home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 1.iso / toolbox / src / exampleCode / opengl / GLUT / test / test7.c < prev    next >
C/C++ Source or Header  |  1996-11-11  |  4KB  |  183 lines

  1.  
  2. /* Copyright (c) Mark J. Kilgard, 1994. */
  3.  
  4. /* This program is freely distributable without licensing fees 
  5.    and is provided without guarantee or warrantee expressed or 
  6.    implied. This program is -not- in the public domain. */
  7.  
  8. #ifdef __sgi
  9. #include <malloc.h>
  10. #endif
  11. #include <stdlib.h>
  12. #include <stdio.h>
  13. #include <glutint.h>
  14. #include <GL/glut.h>
  15.  
  16. int w1, w2;
  17.  
  18. void
  19. display(void)
  20. {
  21.   glClear(GL_COLOR_BUFFER_BIT);
  22. }
  23.  
  24. void
  25. time9(int value)
  26. {
  27.   if (value != 9)
  28.     __glutFatalError("FAIL: time9 expected 9");
  29.   printf("PASS: test7\n");
  30.   exit(0);
  31. }
  32.  
  33. void
  34. time8(int value)
  35. {
  36.   if (value != 8)
  37.     __glutFatalError("FAIL: time8 expected 8");
  38.   glutSetWindow(w1);
  39.   glutReshapeWindow(350, 250);
  40.   glutPositionWindow(20, 200);
  41.   glutSetWindow(w2);
  42.   glutReshapeWindow(50, 150);
  43.   glutPositionWindow(50, 50);
  44.   glutTimerFunc(1000, time9, 9);
  45. }
  46.  
  47. void
  48. time7(int value)
  49. {
  50.   if (value != 7)
  51.     __glutFatalError("FAIL: time7 expected 7");
  52.   glutSetWindow(w1);
  53.   glutShowWindow();
  54.   glutFullScreen();
  55.   glutSetWindow(w2);
  56.   glutShowWindow();
  57.   glutPopWindow();
  58.   glutTimerFunc(1000, time8, 8);
  59. }
  60.  
  61. void
  62. time6(int value)
  63. {
  64.   if (value != 6)
  65.     __glutFatalError("FAIL: time6 expected 6");
  66.   printf("change icon tile for both windows\n");
  67.   glutSetWindow(w1);
  68.   glutSetIconTitle("icon1");
  69.   glutSetWindow(w2);
  70.   glutSetIconTitle("icon2");
  71.   glutTimerFunc(1000, time7, 7);
  72. }
  73.  
  74. void
  75. time5(int value)
  76. {
  77.   if (value != 5)
  78.     __glutFatalError("FAIL: time5 expected 5");
  79.   glutSetWindow(w1);
  80.   if (glutGet(GLUT_WINDOW_X) != 20) {
  81.     printf("WARNING: x position expected to be 20\n");
  82.   }
  83.   if (glutGet(GLUT_WINDOW_Y) != 20) {
  84.     printf("WARNING: y position expected to be 20\n");
  85.   }
  86.   if (glutGet(GLUT_WINDOW_WIDTH) != 250) {
  87.     printf("WARNING: width expected to be 250\n");
  88.   }
  89.   if (glutGet(GLUT_WINDOW_HEIGHT) != 250) {
  90.     printf("WARNING: height expected to be 250\n");
  91.   }
  92.   glutSetWindow(w2);
  93.   if (glutGet(GLUT_WINDOW_X) != 250) {
  94.     printf("WARNING: x position expected to be 250\n");
  95.   }
  96.   if (glutGet(GLUT_WINDOW_Y) != 250) {
  97.     printf("WARNING: y position expected to be 250\n");
  98.   }
  99.   if (glutGet(GLUT_WINDOW_WIDTH) != 150) {
  100.     printf("WARNING: width expected to be 150\n");
  101.   }
  102.   if (glutGet(GLUT_WINDOW_HEIGHT) != 150) {
  103.     printf("WARNING: height expected to be 150\n");
  104.   }
  105.   printf("iconify both windows\n");
  106.   glutSetWindow(w1);
  107.   glutIconifyWindow();
  108.   glutSetWindow(w2);
  109.   glutIconifyWindow();
  110.   glutTimerFunc(1000, time6, 6);
  111. }
  112.  
  113. void
  114. time4(int value)
  115. {
  116.   if (value != 4)
  117.     __glutFatalError("FAIL: time4 expected 4");
  118.   printf("reshape and reposition window\n");
  119.   glutSetWindow(w1);
  120.   glutReshapeWindow(250, 250);
  121.   glutPositionWindow(20, 20);
  122.   glutSetWindow(w2);
  123.   glutReshapeWindow(150, 150);
  124.   glutPositionWindow(250, 250);
  125.   glutTimerFunc(1000, time5, 5);
  126. }
  127.  
  128. void
  129. time3(int value)
  130. {
  131.   if (value != 3)
  132.     __glutFatalError("FAIL: time3 expected 3");
  133.   printf("show both windows again\n");
  134.   glutSetWindow(w1);
  135.   glutShowWindow();
  136.   glutSetWindow(w2);
  137.   glutShowWindow();
  138.   glutTimerFunc(1000, time4, 4);
  139. }
  140.  
  141. void
  142. time2(int value)
  143. {
  144.   if (value != 2)
  145.     __glutFatalError("FAIL: time2 expected 2");
  146.   printf("hiding w1; iconify w2\n");
  147.   glutSetWindow(w1);
  148.   glutHideWindow();
  149.   glutSetWindow(w2);
  150.   glutIconifyWindow();
  151.   glutTimerFunc(1000, time3, 3);
  152. }
  153.  
  154. void
  155. time1(int value)
  156. {
  157.   if (value != 1)
  158.     __glutFatalError("FAIL: time1 expected 1");
  159.   printf("changing window titles\n");
  160.   glutSetWindow(w1);
  161.   glutSetWindowTitle("changed title");
  162.   glutSetWindow(w2);
  163.   glutSetWindowTitle("changed other title");
  164.   glutTimerFunc(2000, time2, 2);
  165. }
  166.  
  167. int
  168. main(int argc, char **argv)
  169. {
  170. #if defined(__sgi)  && !defined(REDWOOD)
  171.   /* XXX IRIX 6.0.1 mallopt(M_DEBUG, 1) busted. */
  172.   mallopt(M_DEBUG, 1);
  173. #endif
  174.   glutInit(&argc, argv);
  175.   w1 = glutCreateWindow("test 1");
  176.   glutDisplayFunc(display);
  177.   w2 = glutCreateWindow("test 2");
  178.   glutDisplayFunc(display);
  179.   glutTimerFunc(1000, time1, 1);
  180.   glutMainLoop();
  181.   return 0;             /* ANSI C requires main to return int. */
  182. }
  183.